<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang='zh-CN' xml:lang='zh-CN' xmlns='http://www.w3.org/1999/xhtml'>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico" />
        <?php echo $this->_var['meta']; ?>
        <?php echo $this->_var['system_css']; ?>
        <?php echo $this->_var['base_css']; ?>
        <?php echo $this->_var['system_js']; ?>
        <script type="text/javascript">
            $(function(){
                
                $('.replay_answer').live('click',function(){
                    $('.commont_answer_id').val($(this).attr('title'));
                    $.fancybox({
                        'content': $('#inline').html()
                    })
                });
                $.ajax({
                    type: 'post',
                    url: '<?php echo $this->_var['site_url']; ?>q2a_ajax/get_votes',
                    cache: false,
                    data: 'id='+<?php echo $this->_var['data']['id']; ?>,
                    dataType: 'json',
                    beforeSend:function(XMLHttpRequest){
                        $("#mood").html("载入中...");
                    },
                    success: function(data){
                        var str = "<button onclick=add_votes(\"up\")>赞成</button>：("+data.up_votes+")    <button onclick=add_votes(\"down\")>反对</button>：("+data.down_votes+")";
                        $("#mood").html(str); 
                    }
                });
            });
        </script>
    </head>
    <body>
        <div id="OSC_Screen">
            <?php echo $this->fetch('header.html'); ?>
            <div id="OSC_Content">
                <?php echo $this->fetch('message.html'); ?>
                <div class='Question'>
                    <div class='Title'>
                        <div class='Asker'><a href="http://my.oschina.net/u/585142" class="ShowUserOutline" target="_blank"><img src="<?php echo $this->_var['asset_path']; ?>images/q2a_default.png" align="absmiddle" alt="EvePooh" title="EvePooh" class="SmallPortrait" user="585142"/></a></div>
                        <div class='QTitle'>
                            <h1><?php echo $this->_var['data']['name']; ?><?php if ($this->_var['data']['points'] != 0): ?>---------<font color="red">赠送积分：<?php echo $this->_var['data']['points']; ?></font><?php endif; ?></h1>
                            <div class='stat'>
                                <a href="#" target="_blank"><?php echo $this->_var['data']['username']; ?></a>
                                发表于 <?php echo $this->_var['data']['timeformat']; ?>,
                                <?php echo $this->_var['data']['answer_count']; ?>回/<?php echo $this->_var['data']['view_count']; ?>阅,
                            </div>
                            <div class='Context'>


                            </div>
                            <div class='clear'></div>
                        </div>
                        <div class='Body'>
                            <div class='Content'>
                                <div class='detail'><?php echo $this->_var['data']['content']; ?><div class='clear'></div></div>
                                <div class='Tags'>
                                    <strong>标签：</strong>		

                                    <?php if (count ( $this->_var['data']['tags'] ) > 0): ?>
                                    <?php $_from = $this->_var['data']['tags']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'tags');if (count($_from)):
    foreach ($_from AS $this->_var['tags']):
?>
                                    <a href='<?php echo $this->_var['site_url']; ?>question/tag/<?php echo $this->_var['tags']['id']; ?>' class='tag project' title='<?php echo $this->_var['tags']['name']; ?>'><?php echo $this->_var['tags']['name']; ?></a>
                                    <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>    
                                    <?php endif; ?>
                                </div>
                                <div class='EditLogs'>
                                    <ul></ul>
                                </div>		</div>

                            <div class='clear'></div>

                            <div id="msg"></div>
                            <div id=mood>
                            </div>
                            <div class="QuestionReplies" style="border-top: 1px solid;">
                                <ul id="top_ul" style="border-bottom: 1px solid;">
                                    <?php $_from = $this->_var['top_answer']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'answer');if (count($_from)):
    foreach ($_from AS $this->_var['answer']):
?>
                                    <li id="answer_<?php echo $this->_var['answer']['id']; ?>" class="Answer" style="background-color: #CCFFCC">
                                        <div class="user"><a target="_blank" name="AnchorAnswer324037" class="ShowUserOutline" href="#"><img align="absmiddle" user="207467" class="SmallPortrait" title="<?php echo $this->_var['answer']['username']; ?>" alt="<?php echo $this->_var['answer']['username']; ?>" src="<?php echo $this->_var['answer']['avatar']; ?>"></a></div>
                                        <div style="width: 500px;">
                                            <div class="time"><a target="_blank" href="#"><?php echo $this->_var['answer']['username']; ?></a> 回答于 <?php echo $this->_var['answer']['add_time']; ?> </div>		
                                            <div class="clear"></div>
                                            <div class="detail" style="margin-left:60px;">
                                                <?php echo $this->_var['answer']['content']; ?></div>
                                        </div>
                                        <div class="clear"></div>
                                        <div id="PostReplies_324037" class="replies">
                                            <?php if (count ( $this->_var['answer']['comments'] ) > 0): ?>
                                            <ul>
                                                <?php $_from = $this->_var['answer']['comments']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'comment');if (count($_from)):
    foreach ($_from AS $this->_var['comment']):
?>
                                                <li><img align="absmiddle" user="207467" class="SmallPortrait" title="<?php echo $this->_var['comment']['username']; ?>" alt="<?php echo $this->_var['comment']['username']; ?>" src="<?php echo $this->_var['comment']['avatar']; ?>" width="35" height="35"><?php echo $this->_var['comment']['username']; ?> 回复说：<?php echo $this->_var['comment']['content']; ?>   时间：<?php echo $this->_var['comment']['add_time']; ?></li>
                                                <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
                                            </ul>
                                            <?php endif; ?>
                                        </div>
                                        <div class="votes" style="float: right;">
                                            <span id="answer_message_<?php echo $this->_var['answer']['id']; ?>"></span>
                                            <span id="answer_votes_<?php echo $this->_var['answer']['id']; ?>">
                                                <a href="javascript:add_answer_votes('up',<?php echo $this->_var['answer']['id']; ?> )">有帮助</a><em>(<?php echo $this->_var['answer']['up_votes']; ?>)</em>&nbsp;|
                                                <a href="javascript:add_answer_votes('down',<?php echo $this->_var['answer']['id']; ?> )">没帮助</a><em>(<?php echo $this->_var['answer']['down_votes']; ?>)</em>&nbsp;|
                                            </span>

                                            <a href="javascript:void(0);" id="replay_answer_<?php echo $this->_var['answer']['id']; ?>" class="replay_answer" title="<?php echo $this->_var['answer']['id']; ?>">回复</a><em>(<?php echo $this->_var['answer']['comment_count']; ?>)</em>&nbsp;|
                                            <?php if ($this->_var['data']['user_id'] == $this->_var['user']['id']): ?>
                                            <?php if (! count ( $this->_var['top_answer'] ) > 0): ?>
                                            <span class="top_span"><a href="javascript:answer_top(<?php echo $this->_var['answer']['id']; ?>)">置顶</a>&nbsp;|</span>
                                            <?php endif; ?>
                                            <?php endif; ?>

                                            <?php if ($this->_var['user']['is_admin'] == 1): ?>

                                            <a href="javascript:delete_answer(<?php echo $this->_var['answer']['id']; ?>)">删除</a>&nbsp;|

                                            <?php endif; ?>
                                        </div>
                                        <div class="clear"></div>
                                    </li>
                                    <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>

                                </ul>
                                <ul class="list" id="answer_list">
                                    <?php $_from = $this->_var['common_answer']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'answer');if (count($_from)):
    foreach ($_from AS $this->_var['answer']):
?>
                                    <li id="answer_<?php echo $this->_var['answer']['id']; ?>" class="Answer">
                                        <div class="user"><a target="_blank" name="AnchorAnswer324037" class="ShowUserOutline" href="#"><img align="absmiddle" user="207467" class="SmallPortrait" title="<?php echo $this->_var['answer']['username']; ?>" alt="<?php echo $this->_var['answer']['username']; ?>" src="<?php echo $this->_var['answer']['avatar']; ?>"></a></div>
                                        <div style="width: 500px;">
                                            <div class="time"><a target="_blank" href="#"><?php echo $this->_var['answer']['username']; ?></a> 回答于 <?php echo $this->_var['answer']['add_time']; ?> </div>		
                                            <div class="clear"></div>
                                            <div class="detail" style="margin-left:60px;">
                                                <?php echo $this->_var['answer']['content']; ?></div>
                                        </div>
                                        <div class="clear"></div>
                                        <div id="PostReplies_324037" class="replies">
                                            <?php if ($this->_var['answer']['comments_count'] != 0): ?>
                                            <p style="text-align:center">=========================共有：<?php echo $this->_var['answer']['comments_count']; ?> 条评论==========================</p>
                                            <?php endif; ?>


                                            <?php if (count ( $this->_var['answer']['comments'] ) > 0): ?>
                                            <ul>
                                                <?php $_from = $this->_var['answer']['comments']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'comment');if (count($_from)):
    foreach ($_from AS $this->_var['comment']):
?>
                                                <li><img align="absmiddle" user="207467" class="SmallPortrait" title="<?php echo $this->_var['comment']['username']; ?>" alt="<?php echo $this->_var['comment']['username']; ?>" src="<?php echo $this->_var['comment']['avatar']; ?>" width="35" height="35"><?php echo $this->_var['comment']['username']; ?> 回复说：<?php echo $this->_var['comment']['content']; ?>   时间：<?php echo $this->_var['comment']['add_time']; ?></li>
                                                <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
                                            </ul>
                                            <?php endif; ?>

                                        </div>
                                        <div class="votes" style="float: right;">
                                            <span id="answer_message_<?php echo $this->_var['answer']['id']; ?>"></span>
                                            <span id="answer_votes_<?php echo $this->_var['answer']['id']; ?>">
                                                <a href="javascript:add_answer_votes('up',<?php echo $this->_var['answer']['id']; ?> )">有帮助</a><em>(<?php echo $this->_var['answer']['up_votes']; ?>)</em>&nbsp;|
                                                <a href="javascript:add_answer_votes('down',<?php echo $this->_var['answer']['id']; ?> )">没帮助</a><em>(<?php echo $this->_var['answer']['down_votes']; ?>)</em>&nbsp;|
                                            </span>

                                            <a href="javascript:void(0);" id="replay_answer_<?php echo $this->_var['answer']['id']; ?>" class="replay_answer" title="<?php echo $this->_var['answer']['id']; ?>">回复</a><em>(<?php echo $this->_var['answer']['comment_count']; ?>)</em>&nbsp;|
                                            <?php if ($this->_var['data']['user_id'] == $this->_var['user']['id']): ?>
                                            <?php if (! count ( $this->_var['top_answer'] ) > 0): ?>
                                            <span class="top_span"><a href="javascript:answer_top(<?php echo $this->_var['answer']['id']; ?>)">置顶</a>&nbsp;|</span>
                                            <?php endif; ?>
                                            <?php endif; ?>

                                            <?php if ($this->_var['user']['is_admin'] == 1): ?>

                                            <a href="javascript:delete_answer(<?php echo $this->_var['answer']['id']; ?>)">删除</a>&nbsp;|

                                            <?php endif; ?>
                                        </div>
                                        <div class="clear"></div>
                                    </li>
                                    <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
                                </ul>
                                <p><?php echo $this->_var['page']; ?></p>
                            </div>
                            <div class='AnswerForm'>
                                <div>
                                    <input type="hidden" id="answer_category_id" value="<?php echo $this->_var['data']['category_id']; ?>"/>

                                    <input type="hidden" id="answer_parent_id" value="<?php echo $this->_var['data']['id']; ?>"/>
                                    <textarea id='answer_content' name='content' style='width:560px;height:160px;'></textarea>
                                    <tr>
                                        <th>验证码：</th>		
                                        <td><input type='text' id='captcha' name='captcha' size='8' class='TEXT'/>
                                        </td>
                                    </tr>
                                    <tr>
                                        <th>&nbsp;</th>		
                                        <td>
                                            <?php echo $this->_var['captcha']; ?>
                                        </td>
                                    </tr>
                                    <?php if (count ( $this->_var['user'] ) > 0): ?>
                                    <input type='button' value=' 我要回答 ' id="answer_click" class='rndbutton'/> <span class="answer_message"></span>
                                    <?php else: ?>
                                    <input type='button' value=' 我要回答 ' id="answer_click" class='rndbutton' disabled/>
                                    <span id='form_msg' style=''>请先登录 <a href='<?php echo $this->_var['site_url']; ?>user/login'>点击这里</a></span>
                                    <?php endif; ?>

                                    <br/><br/>
                                </div>
                                <div class='clear'></div>
                            </div>
                        </div>
                        <div class='QuestionRelations'>
                            <div id='QuestionWizard'>
                                您要提问吗？
                                <a href='<?php echo $this->_var['site_url']; ?>question/ask' class='rndbutton'><span>我要提问</span></a>
                                <div class='clear'></div>
                            </div>

                            <div id='OtherQuestionsOfUser' class='Qlist'>
                                <strong><em><?php echo $this->_var['data']['username']; ?></em>的其他问题</strong>
                                <ul>
                                    <?php if (count ( $this->_var['user_related_questions'] ) > 0): ?>
                                    <?php $_from = $this->_var['user_related_questions']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'related_question');if (count($_from)):
    foreach ($_from AS $this->_var['related_question']):
?>
                                    <li><a href="<?php echo $this->_var['related_question']['url']; ?>" title="<?php echo $this->_var['related_question']['name']; ?>"><?php echo $this->_var['related_question']['name']; ?></a><span class='date'>(<?php echo $this->_var['related_question']['answer_count']; ?>回/<?php echo $this->_var['related_question']['view_count']; ?>阅,<?php echo $this->_var['related_question']['timeformat']; ?>)</span></li>
                                    <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
                                    <?php endif; ?>

                                </ul>
                            </div>
                            <div style='text-align:center;margin-bottom:20px;'>
                                <script type="text/javascript" src="../js/ad/question.js"></script>
                            </div>
                            <div id='Similarity' class='Qlist'>
                                <strong>类似的话题</strong>
                                <ul>
                                    <?php if (count ( $this->_var['category_related_questions'] ) > 0): ?>
                                    <?php $_from = $this->_var['category_related_questions']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'related_question');if (count($_from)):
    foreach ($_from AS $this->_var['related_question']):
?>
                                    <li><a href="<?php echo $this->_var['related_question']['url']; ?>" title="<?php echo $this->_var['related_question']['name']; ?>"><?php echo $this->_var['related_question']['name']; ?></a><span class='date'>(<?php echo $this->_var['related_question']['answer_count']; ?>回/<?php echo $this->_var['related_question']['view_count']; ?>阅,<?php echo $this->_var['related_question']['timeformat']; ?>)</span></li>
                                    <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
                                    <?php endif; ?>
                                </ul>
                            </div>
                        </div>
                        <div class='clear'></div>   
                    </div>

                </div>
                <div class='clear'></div>
                <?php echo $this->fetch('footer.html'); ?>
            </div>

            <div style="display:none">
                <div id="inline" style=" overflow:auto">
                    <?php if (count ( $this->_var['user'] ) > 0): ?>
                    <form action="<?php echo $this->_var['site_url']; ?>comment/add" method="post">
                        <input name="question_id" type="hidden" value="<?php echo $this->_var['data']['id']; ?>"/>
                        <input type="hidden" id="page" value="<?php echo $this->_var['page_num']; ?>" name="page"/>
                        <input class="commont_answer_id" type="hidden" name="parent_id"/>
                        <textarea id='commont_content' name='content' style='width:360px;height:160px;'></textarea>
                        <input type='submit' value=' 我要回复 '  class='rndbutton commont_click'/> <span class="commont_message"></span>
                    </form>
                    <?php else: ?>
                    请先登录,登录请<a href="<?php echo $this->_var['site_url']; ?>user/login">点这里</a>
                    <?php endif; ?>
                </div>
            </div>
            <script>
                
                
                function add_votes(act){
                    id = <?php echo $this->_var['data']['id']; ?>;
                    $.ajax({
                        type: 'post',
                        url: '<?php echo $this->_var['site_url']; ?>q2a_ajax/get_votes',
                        cache: false,
                        data: 'id='+id+'&act='+act,
                        dataType: 'json',
                        beforeSend:function(XMLHttpRequest){
                            $("#mood").html("载入中...");
                        },
                        success: function(data){
                            var str = "<button onclick=add_votes(\"up\")>赞成</button>：("+data.up_votes+")    <button onclick=add_votes(\"down\")>反对</button>：("+data.down_votes+")";
                            $("#mood").html(str); 
                            if(data.message != ''){
                                var message = "<font color=\"red\">"+data.message+"</font>";
                                $("#msg").show().html(message).fadeOut(2000);
                            }
                        }
                    });
                }
                $(function(){
                    
                    $('#answer_click').click(function(){
                        var answer_content = $('#answer_content').val();
                        var parent_id = $('#answer_parent_id').val();
                        var captcha = $('#captcha').val();
                        var answer_category_id = $('#answer_category_id').val();
                        if(answer_content ==''){
                            $('.answer_message').show().html('<font color=red>评论内容不能为空</font>').fadeOut(3000);
                        } else if(captcha == ''){
                            $('.answer_message').show().html('<font color=red>验证码不能为空</font>').fadeOut(3000);
                        }else{
                            
                            
                            $.ajax({
                                type: 'post',
                                url: '<?php echo $this->_var['site_url']; ?>q2a_ajax/add_answer',
                                cache: false,
                                data: 'content='+answer_content+'&parent_id='+parent_id+'&category_id='+answer_category_id+'&catpcha='+captcha,
                                dataType: 'html',
                                beforeSend:function(XMLHttpRequest){
                                    $(".answer_message").show().html("操作中... ...");
                                },
                                success: function(data){
                                    document.getElementById('captcha_change').src = '<?php echo $this->_var['site_url']; ?>captcha/default?r='+Math.random();
                                    if(data == 0){
                                        $('.answer_message').show().html('<font color=blue>验证码错误</font>').fadeOut(3000);
                                    }else{
                                        $("#answer_list").append(data);
                                        $('.answer_message').show().html('<font color=blue>添加成功</font>').fadeOut(3000);
                                    }
                                    
                                }
                            });
                        }
                    });
                });
                function answer_top(id){
                    $.ajax({
                        type: 'post',
                        url: '<?php echo $this->_var['site_url']; ?>q2a_ajax/answer_top',
                        cache: false,
                        data: 'id='+id,
                        dataType: 'text',
                        success: function(data){
                            if(data.match(/^[0-9].*$/)){
                                $('.top_span').remove();
                                $top_html = $('#answer_'+id).remove();
                                $('#top_ul').html($top_html);
                                $('#top_ul').css('background-color','#CCFFCC')
                            
                                jSuccess("恭喜，操作成功! + <strong>"+data+"</strong> 积分!",{
                                    VerticalPosition : 'center',
                                    HorizontalPosition : 'center'
                                });
                            } else{
                                jError(data,{
                                    VerticalPosition : 'center',
                                    HorizontalPosition : 'center'
                                });
                            }
                        }
                    });
                }
                
                
                function add_answer_votes(act,id){
                    $.ajax({
                        type: 'post',
                        url: '<?php echo $this->_var['site_url']; ?>q2a_ajax/get_votes',
                        cache: false,
                        data: 'id='+id+'&act='+act,
                        dataType: 'json',
                        beforeSend:function(XMLHttpRequest){
                            $("#answer_votes_"+id).html("载入中...");
                        },
                        success: function(data){
                            var str = "<a href=javascript:add_answer_votes(\"up\","+data.id+")>有帮助</a><em>("+data.up_votes+")</em>&nbsp;|"+
                                "<a href=javascript:add_answer_votes(\"down\","+data.id+")>没帮助</a><em>("+data.down_votes+")</em>&nbsp;|";
                            $("#answer_votes_"+id).html(str); 
                            if(data.message != ''){
                                var message = "<font color=\"red\">"+data.message+"</font>";
                                $("#answer_message_"+id).show().html(message).fadeOut(2000);
                            }
                        }
                    });
                }
                
                   
                
                function delete_answer(id){
                    jNotify("注意：点击这里确认删除，取消请在空白处点击右键“重新载入页面”",{
                        VerticalPosition : 'center',
                        HorizontalPosition : 'center',
                        autoHide:false,
                        clickOverlay:true,
                        TimeShown : 3000,
                        onClosed:function(){
                            $.ajax({
                                type: 'post',
                                url: '<?php echo $this->_var['site_url']; ?>q2a_ajax/delete_answer',
                                cache: false,
                                data: 'id='+id,
                                dataType: 'text',
                                success: function(data){
                                    if(data == 0){
                                        jError('删除失败，请重新操作!',{
                                            VerticalPosition : 'center',
                                            HorizontalPosition : 'center'
                                        });
                                    } else{
                                        $('#answer_'+id).remove();
                                        jSuccess("恭喜，删除成功!",{
                                            VerticalPosition : 'center',
                                            HorizontalPosition : 'center'
                                        });
                                    }
                                }
                            });
                        }
                    });
                }
            </script>
    </body>
</html>
